<div id="manage-file-list"
     data-topple="hsList"
     data-load-url="common/fold/search.act?path=${path}&amp;type=file&amp;ob=name"
     data-send-urls-0="['common/fold/delete.act','.delete','您确定要删除此文件?']"
     data--0="_fill_size: ( function(x, v) {return humanSize(v);} )"
     data--1="_empty_err: 没有文件, 您可以添加文件, 或查看下级目录!">
    <div class="toolbox board">
        <div class="btn-group">
            <button type="button" class="create btn btn-default">新建文件</button>
            <button type="button" class="modify for-choose btn btn-default">打开</button>
            <!--
            <button type="button" class="dnload for-checks btn btn-default">下载</button>
            <button type="button" class="upload for-nobody btn btn-default">上传</button>
            //-->
            <button type="button" class="delete for-checks btn btn-default" title="删除"><span class="bi bi-hi-remove text-danger"></span></button>
        </div>
    </div>
    <div class="listbox panel panel-default table-responsive">
        <table class="table table-hover table-striped table-compressed">
            <thead>
                <tr>
                    <th data-fn="path[]" data-ft="_check" class="_check">
                        <input type="checkbox" class="checkall" name="path[]"/>
                    </th>
                    <th data-fn="name" class="sortable">文件名</th>
                    <th data-fn="type" class="sortable">类型</th>
                    <th data-fn="size" class="sortable">大小</th>
                    <th data-fn="mtime" data-ft="_htime" class="_htime sortable">修改时间</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </div>
    <div class="pagebox"></div>
    <div class="well" style="display: none;">
        <h2>使用帮助</h2>
        <p><br/></p>
        <p style="line-height: 2em; margin-bottom: 1em;">
            可管理网站、配置、数据等文件，
            首先请选择需要管理的一级目录，
            然后即可操作其下的文件或目录。
        </p>
        <p style="line-height: 2em; margin-bottom: 1em;">
            仅支持查看和编辑常规文本文件，
            但禁止操作服务端可运行的文件，
            务必谨慎修改配置或数据等文件。
        </p>
        <p style="line-height: 2em;">
            <b>祝您使用顺利！</b>
        </p>
        <p><br/></p>
    </div>
    <form class="invisible">
        <input type="file" name="file"/>
    </form>
</div>
<script type="text/javascript">
    (function($) {
        var context = H$("#manage-file-list");
        var loadbox = context.closest(".loadbox");
        var loadpms = hsSerialArr(loadbox       );
        var path    = hsGetSeria (loadpms,"path");

        if (path === '/') {
            context.removeAttr("data-load-url");
            context.find(".well"   ).show();
            context.find(".listbox").hide();
            context.find(".pagebox").hide();
            context.find(".toolbox").find("input,button").prop("disabled", true);
        }

        context.data("fillPage", function(page) {
            if (page.state > 0 ) {
                context.find(".pagebox").hide();
                return ;
            }
            HsList.prototype.fillPage.call(this, page);
        });

        context.data("_fill__check", function(td, v, n) {
            HsList.prototype._fill__check.call ( this, td, v, n );
            $(td).find(":checkbox").data("type", this._info.type);
        });

        context.data("_fill_name", function(td, v) {
            if (this._info.type == "txt") {
                td = $('<a href="javascript:;" class="modify"></a>')
                  .appendTo(td);
            }   td.text (  v  );
        });

        context.on("click", ".create", function( ) {
            var inst  =  context.data("HsList");
            inst.open($(this), $(this).hsFind("@"),
            "centra/manage/file/file_form.html?path="+encodeURIComponent(path));
        });

        context.on("click", ".modify", function( ) {
            var inst  =  context.data("HsList");
            var item  =  inst.getIds (  this  );
            if (item === null ) {
                return;
            }
            var type  =  item.data("type");
            var path  =  item.val ( /**/ );
            if (type !== "txt") {
                $.hsWarn("抱歉, 暂不支持编辑非文本文件", "warning");
                return;
            }
            inst.open($(this), $(this).hsFind("@"),
            "centra/manage/file/file_edit.html?path="+encodeURIComponent(path));
        });

        context.on("click", ".upload,.dnload", function() {
            $.hsWarn("抱歉, 暂不支持上传和下载", "warning");
        });

        // 自适滚动
        hsFlexRoll(context.find(".listbox"), $("#main-context"));
    })(jQuery);
</script>